Copyright (c) 1999 Massachusetts Institute of Technology

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, see https://gnu.org/licenses or write
to:
  Free Software Foundation, Inc.
  51 Franklin Street, Fifth Floor
  Boston, MA 02110-1301
  USA
------------------------------

MLDEV/MLSLV protocol

The MLDEV protocol is a binary file transfer protocol used between ITS
systems for the transfer of files.  It depends heavily upon the ITS job
device feature and the ITS system calls and error codes.  For a more
detailed description of the ITS system calls, read the ITS UUO and
symbolic system call manuals.

The name MLDEV is historical, dating back to the days when this protocol
was used mostly to reference ML's file system from AI (and vice versa).
The MLDEV server is called MLSLV, for "ML slave".

ICP is to socket 305 if doing mostly input, 307 if mostly output.
User commands:

Command format:	to slave
AOBJN pointer (RH = command code)
Block of arguments

Command codes:
COPENI==1	OPEN for input
		arg1:	Device
		arg2:	FN1
		arg3:	FN2
		arg4:	SNAME
		arg5:	OPEN mode

COPENO==2	OPEN for output
		arg1:	Device
		arg2:	FN1
		arg3:	FN2
		arg4:	SNAME
		arg5:	OPEN mode

CDATA==3	Write data (Word count includes data words and byte count word)
		arg1:	# of bytes of data
		args:	Data, packed ILDB-style into at most 200 words

CALLOC==4	Read allocate
		Allocation in bytes

CICLOS==5	Input CLOSE
		Ignored argument

COCLOS==6	Output CLOSE
		Ignored argument

CFDELE==7	DELETE or RENAME
		arg1:  Device
		arg2:	FN1
		arg3:	FN2
		arg4:	0 or new FN1
		arg5:	0 or new FN2
		arg6:	SNAME

CRNMWO==10	RENAME while open
		arg1:	new FN1
		arg2:	new FN2

CNOOP=11	No-op
		arg:	Echoed by the no-op reply

CACCES==12	ACCESS
		arg1:	Transaction number
		arg2:	Access pointer
		arg3:	New allocation

CSYSCL==13	Random system call.  11 (decimal) arguments
		arg1:	System call name in sixbit
		arg2:	Flags (control-bit argument)
		arg3:	Number of following arguments that have significance
		arg4:	1st argument to system call
		...
		arg11:	8th argument to system call

CREUSE==14	Reinitialize yourself, because we are about to be reused
		by a new creator for a new file
Server replies

Reply format:	from slave
AOBJN pointer (RH = reply code)
Block of arguments

R==,,-1		Reply codes:

RDATA==1	Input data (word count includes data words and byte count word)
		arg1:	# of bytes of data
		args:	Data, packed ILDB-style into words.
		Note:  Slave must always send fully populated words except when
		EOF is reached.

ROPENI==2	Input OPEN status; 1 or 11 arguments
		arg1: -1  succeeded >0  OPEN loss number
		arg2arg11 are present only if arg1 is -1
		 arg2:	Real device name (usually SIXBIT/DSK/)
		 arg3:	 Real FN1
		 arg4:	Real FN2
		 arg5:	Real SNAME
		 arg6:	File length
		 arg7:	Byte size open in
		 arg8:	File length in byte size written in
		 arg9:	Byte size written in
		 arg10:	FILDTP - -1 if RFDATE wins on this file
		 arg11: Creation data (if RFDATE wins)

ROPENO==3	Output OPEN status.  1 or 11 arguments
		arg1:	-1  succeeded >0  OPEN loss number
		arg2-arg11 present only if arg1 is -1
		 arg2:	Real device name
		 arg3:	Real FN1
		 arg4:	Real FN2
		 arg5:	Real SNAME
		 arg6:	File length (-1  FILLEN fails on this device)
		 arg7:	Byte size open in
		 arg8:	File length in byte size written in
		 arg9:	Byte size written in
		 arg10:	FILDTP - -1 if RFDATE wins on this file
		 arg11: Creation data (if RFDATE wins)

REOF==4		EOF on input
		Ignored argument

RFDELE==5	DELETE/RENAME status.  1st argument:
		RH:	-1  succeeded
			0  failure code
		LH:	-1  DELETE or RENAME
			 0  RENAME while open
		If RENAME while open call succeeded, there are 4 more arguments:
		 arg2:	Real device name
		 arg3:	Real FN1 (as renamed)
		 arg4:	Real FN2
		 arg5:	Real SNAME

RNOOP==6	No-op reply
		arg:	Echo argument send by no-op command

RACCES==7	Acknowledge access
		arg:	Transaction number from CACCES

RSYSCL==10	Respond to system call.  9 arguments
		arg1:	<error code or 0>,,<# of times call skipped>
		arg2:	1st value from system call
		...
		arg9:	8th value from system call

RICLOS==11	Respond to input CLOSE

ROCLOS==12	Respond to output CLOSE

RIOC==13	Reflect an IOC error
		arg:	IOC error code, right-justified in word

RREUSE==14	Acknowledge a CREUSE
		Ignored argument
